package com.example.Laboratory.Mapper;


import com.example.Laboratory.Entity.Carousel;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CarouselMapper {

    //查看所有轮播图
    @Select("SELECT * FROM carousel")
    List<Carousel> SeAll ( );

    //通过id查找轮播图地址
    @Select("SELECT carousel_address FROM carousel WHERE carousel_id =#{carousel_id}")
    String researchAddress (int carousel_id);

    //查找level是否已存在
    @Select("SELECT carousel_level FROM carousel WHERE carousel_level=#{carousel_level}")
    String researchLevel (int carousel_level);

    //添加轮播图
    @Insert("INSERT INTO carousel (carousel_address,carousel_level) VALUES (#{carousel_address},#{carousel_level})")
    int addCarousel (Carousel carousel);

    //查找条数
    @Select("SELECT count(*) FROM carousel")
    int researchNumber ( );

    //通过id修改轮播图等级
    @Update("UPDATE carousel SET carousel_level =#{carousel_level},carousel_address =#{carousel_address} WHERE carousel_id =#{carousel_id}")
    int reviseCarousel (Carousel carousel);

    //删除轮播图
    @Delete("DELETE FROM carousel WHERE carousel_id = #{carousel_id}")
    int deleteCarousel (int carousel_id);

}
